Contents | Index | < Browse | Browse >

LETTERlabsULETTER Returns the absolute value of a long integer.

Overview
#include <stdlib.h>

r = labs(l);

long int r;
long int l;

Portability
ANSI

Description
This function returns the absolute value of the long integer argument passed to it. You may alternatively define a macro like this:
#define labs(l) ((l) < 0 ? -(l) : (l))
With this macro however "l" will be evaluated three times and should thus never be passed as a complex expression. For this reason you should prefer the function to the macro.

Returns
The absolute value.

See also
abs , fabs